//
//  MyAccountViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/28.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "MyAccountViewController.h"
#import "MyAccountView.h"
#import "MySelfTableViewCell.h"

@interface MyAccountViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)MyAccountView * myView;

@property (nonatomic, strong)UITableView * tableView;

@property (nonatomic, strong)NSArray * imageNameArray;

@property (nonatomic, strong)NSArray * showStringArray;

@end

@implementation MyAccountViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    _showStringArray = @[@"出金",@"入金",@"实名认证",@"银行卡",@"手机号"];
    _imageNameArray = @[@"出金",@"入金2",@"实名认证",@"银行卡",@"手机号2"];
    
    [self setupNavBar];
    [self setupUI];
}



- (void)setupNavBar{
    
    self.title = @"我的账户";
    
    UIButton * nextButton = [[UIButton alloc] init];
    
    nextButton.frame = CGRectMake(0 * SCREENH6, 0 * SCREENH6, 55 * SCREENH6, 25 * SCREENH6);
    nextButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    [nextButton setImage:[UIImage imageNamed:@"明细"] forState:UIControlStateNormal];
    [nextButton setTitle:@"明细" forState:UIControlStateNormal];
    
    [nextButton addTarget:self action:@selector(pushToInformationVC) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * rightButton = [[UIBarButtonItem alloc] initWithCustomView:nextButton];
    
    self.navigationItem.rightBarButtonItem = rightButton;
    
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToMySelfVC) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}


- (void)setupUI{
    
    MyAccountView * accountView = [[MyAccountView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 248 * SCREENH6)];
    
    [self.view addSubview:accountView];
    
    CGFloat y = CGRectGetMaxY(accountView.frame);
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y,SCREEN_WIDTH ,SCREENH_HEIGHT - y)];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"背景"]];
    
    self.tableView.separatorColor = [UIColor darkGrayColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.bounces = NO;
    
    [self.tableView registerClass:[MySelfTableViewCell class] forCellReuseIdentifier:@"myselfCell"];
    
    [self.view addSubview:self.tableView];
    
}



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    MySelfTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myselfCell" forIndexPath:indexPath];
    
    cell.explationLabel.text = self.showStringArray[indexPath.row];
    cell.iconImage.image = [UIImage imageNamed:self.imageNameArray[indexPath.row]];
    
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 60 * SCREENH6;
    
}



- (void)backToMySelfVC{
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)pushToInformationVC{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
